import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
export const formSchema = [
  // {
  //     component: 'Input',
  //     defaultValue: '',
  //     fieldName: 'id',
  //     label: '字典编号',
  //     componentProps: {
  //         placeholder: '请输入编号',
  //     },
  // },
  {
    component: 'Input',
    defaultValue: '',
    fieldName: 'name',
    label: '字典名称',
    componentProps: {
      placeholder: '请输入字典名称',
    },
  },
];
/** 表头 */
export function useColumns<T>(
  onActionClick: OnActionClickFn<T>,
): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'id',
      title: '字典编号',
      width: 200,
    },
    {
      field: 'name',
      title: '字典名称',
      width: 200,
    },
    {
      field: 'valueType',
      title: '类型',
      width: 200,
    },
    {
      field: 'value',
      title: '值',
      width: 200,
    },
    {
      field: 'remark',
      minWidth: 100,
      title: '备注',
    },
    {
      align: 'center',
      cellRender: {
        attrs: {
          nameField: 'name',
          nameTitle: '字典名称',
          onClick: onActionClick,
        },
        name: 'CellOperation',
      },
      field: 'operation',
      fixed: 'right',
      title: '操作',
      width: 130,
    },
  ];

}

/**表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      component: 'Input',
      componentProps: {
        placeholder: '请输入字典编号',
      },
      fieldName: 'id',
      label: '字典编号',
      rules: 'required',
    },
    {
      component: 'Input',
      componentProps: {
        placeholder: '请输入字典名称',
      },
      fieldName: 'name',
      label: '字典名称',
      rules: 'required',
    },
    {
      component: 'Select',
      componentProps: {
        placeholder: '请选择类型',
        options: [
          { label: '字符串', value: '字符串' },
          { label: '数字', value: '数字' },
          {
            label: '数组',
            value: '数组',
          },
        ],
      },
      fieldName: 'valueType',
      label: '类型',
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入字典值',
        rows: 5,
      },
      fieldName: 'value',
      label: '字典值',
      rules: 'required',
    },
    {
      component: 'Input',
      componentProps: {
        placeholder: '请输入备注',
      },
      fieldName: 'remark',
      label: '备注',
    },
  ];
}


